package com.dao.impl;

import com.dao.LoginDao;
import com.entity.User;
import com.utils.DBUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.Connection;
import java.sql.SQLException;

public class LoginDaoimpl implements LoginDao {

    QueryRunner runn = new QueryRunner();

    @Override
    public User login(String uName,String uPass) {
        String sql = "select * from meacth where uname=? and upass=?;";
        Connection conn = DBUtil.openconn();
        User user = null;
        try {
            user = runn.query(conn,sql,new BeanHandler<User>(User.class),uName,uPass);
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return user;
    }
}
